/*
 * SubjectsRead.java
 *
 * Created on November 16, 2008, 8:21 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package jollylengkono.skripsi.Subjects.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jollylengkono.skripsi.dao.SubjectsDao;
import jollylengkono.skripsi.model.Subjects;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

/**
 *
 * @author JollkY
 */
public class SubjectsRead {
    private String FORWARD;
    
    /** Creates a new instance of SubjectsRead */
    public SubjectsRead() {
    }
    
    public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response) {
        long id = Long.parseLong(request.getParameter("sub_id"));
        Subjects subj = (Subjects) new SubjectsDao().read(id);
        if (subj==null) {
            this.FORWARD="fail";
        } else {
            this.FORWARD="success";
            request.setAttribute("subj", subj);
        }
        return mapping.findForward(FORWARD);
    }
    
}
